package com.sds.sweng.swat.miplatform.service.figures.components;

import org.dom4j.Node;
import org.eclipse.draw2d.Graphics;

import com.sds.sweng.swat.miplatform.service.validation.ValidationInfo;
import com.sds.sweng.swat.miplatform.service.validation.ValidationProperties;
import com.sds.sweng.swat.miplatform.service.validation.ValidationProperty;
import com.sds.sweng.swat.miplatform.service.validation.ValidationType;

public class CalendarComponent extends TextboxComponent {

	public CalendarComponent(Node component, Node parent) {
		super(component, parent);
	}

	public ValidationProperty[] getValidationProperties(ValidationInfo validationInfo) {
		return new ValidationProperty[] {
			new ValidationProperty(ValidationProperties.COMPONENT_NAME , validationInfo.componentName),
			new ValidationProperty(ValidationProperties.ID, validationInfo.id),
			new ValidationProperty(ValidationProperties.BUSINESS_NAME, validationInfo.businessName),
			new ValidationProperty(ValidationProperties.TYPE, validationInfo.type),
			new ValidationProperty(ValidationProperties.REQUIRED, validationInfo.required),
			new ValidationProperty(ValidationProperties.REQUIRED_GROUP, validationInfo.requiredGroup),
			new ValidationProperty(ValidationProperties.MIN, validationInfo.min),
			new ValidationProperty(ValidationProperties.MAX, validationInfo.max),
			new ValidationProperty(ValidationProperties.COMPARE_OP, validationInfo.compOp),
			new ValidationProperty(ValidationProperties.COMPARE_TARGET, validationInfo.compTarget)
		};
	}

	public String[] getValidationTypes() {
		return new String[] {
			ValidationType.NONE,
			ValidationType.CUSTOM
		};
	}

	protected void paintFigure(Graphics graphics) {
		super.paintFigure(graphics);

		int x = bounds.x+bounds.width-20;
		int y = bounds.y;

		graphics.drawLine(x, y, x, y+bounds.height);

		for (int i=0;i<(bounds.height-5)/3;i++) {
			graphics.drawLine(x, y+5+i*3, x+bounds.width, y+5+i*3);
		}

		for (int i=1;i<20/3;i++) {
			graphics.drawLine(x+i*3, y+5, x+i*3, y+bounds.height);
		}
	}

}
